<template>
	<view>

		<!--返回-->
		<view class="jiangqie-back-btn" @click="jumpBtn">
			<image src="@/static/images/new/back.png" mode="widthFix"></image>
		</view>
		
		<view class="container jiangqie-page-view">
			<video class="image-self" style="height: 100vh;width: 100vw;display: flex;" mode="aspectFill"
				v-if="detailData" :src="detailData.movie.image"
				:title="detailData.movie.image" :show-mute-btn="true"
				:autoplay="true" :loop="true" :page-gesture="true"
				:poster="detailData.movie.thumbnail"></video>
		</view>
				
	</view>
</template>

<script>

	/*
	 * Author: 郭少
	 * github: https://github.com/guoshao99/wallpaper-applet
	 * gitee: https://gitee.com/guoshao99/wallpaper-applet
	 * QQ：2549789059
	 * 微信：2549789059
	 */

	import http from '@/utils/http.js'
	
	export default {
		components: {
		},
		data() {
			return {
				resourceId: null,
				page: null,
				detailData: null
				
			};
		},
		onUnload() {
		},
		onLoad: function(options) {
			this.resourceId = options.resourceId
			
			this.resourceDetail()

		},
		onShow: function() {

		},
		onHide() {
			
		},
		
		onShareAppMessage: function() {
			let that = this;
			let share_title = '免费观看电视，电影，动漫视频解说';

			uni.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			});
			return {
				title: share_title,
				imageUrl: null,
				path: 'pages/filmVideo/filmVideo?resourceId='
			};
		},
		onShareTimeline: function() {
			let that = this;
			let share_title = "免费观看电视，电影，动漫视频解说"
			return {
				title: share_title,
				query: 'resourceId=',
				imageUrl: null
			};
		},

		methods: {
			resourceDetail(){
				var params = {
					url: `/platform/u/resourceDetail/${this.resourceId}`,
					method: "GET",
					data: {},
					callBack: (res)=> {
						if(res.code == 200){
							this.detailData = res.data
							//更新播放记录
							this.renewPLayRecord()
						}else{
							uni.showToast({
								title: '获取视频失败',
								success() {
									setTimeout(uni.navigateBack(),500)
								}
							})
						}
					}
				};
				http.request(params);
			},
			
			//更新播放记录
			renewPLayRecord(){
				var params = {
					url: `/film/playRecord/u/addOrUpdate/${this.resourceId}`,
					method: "POST",
					data: {},
					callBack: function(res) {
						if(res.code == 200){
							console.log('更新成功')
						}else{
							console.log('更新失败')
						}
					}
				};
				http.request(params);
			},
			/**
			 * 跳转返回
			 */
			jumpBtn() {
				if (this.page == 'index') {
					uni.switchTab({
						url: '/pages/index/index'
					});
				} else {
					uni.navigateBack();
				}
			},

		}
	};
</script>
<style>
	@import './article.css';
</style>
